from django.conf.urls.defaults import patterns, include, url
from django.contrib import admin
from django.conf import settings
from django.contrib.comments.feeds import LatestCommentFeed
from django.views.generic.simple import redirect_to
from PyBlog.apps.blog.models import BlogSitemap, CategoriesSitemap
from django.contrib.sitemaps import FlatPageSitemap

admin.autodiscover()
sitemaps = {'blog': BlogSitemap,'flatpages': FlatPageSitemap,'categoris':CategoriesSitemap}
urlpatterns = patterns('',
    #administration
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    url(r'^accounts/login/', include(admin.site.urls)),
    url(r'^admin/', include(admin.site.urls)),
    #apps
    url(r'^blog/', include('apps.blog.urls')),
    url(r'^comments/', include('django.contrib.comments.urls')),
    url(r'^projects/', include('apps.projects.urls')),
    url(r'^captcha/', include('apps.captcha.urls')),
    #apis
    url(r'^feeds/latest/$', LatestCommentFeed()),
    url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
    url(r'^xmlrpc/$', 'django_xmlrpc.views.handle_xmlrpc'),

    #redirections 
    #url(r'^$', redirect_to , {'url' : '/blog/'}),
    
)

if settings.DEBUG:
    urlpatterns += patterns('',
                url(r'^media/(?P<path>.*)', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True, }),
                )
if 'tinymce' in settings.INSTALLED_APPS: 
    urlpatterns += patterns('',
                            url(r'^tinymce/', include('tinymce.urls')),
                            )    
